package com.csyf.manager.service.impl;

import com.csyf.manager.dao.SysFreezeDao;
import com.csyf.manager.entity.SysFreeze;
import com.csyf.manager.service.SysFreezeBiz;
import com.csyf.manager.utils.page.JqGridVo;
import com.csyf.manager.utils.page.PageUtils;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 冻结ServiceImpl
 */
@Slf4j
@Service
public class SysFreezeBizImpl implements SysFreezeBiz {

    @Autowired
    private SysFreezeDao sysFreezeDao;

    /**
     * 冻结列表
     * @param vo
     * @param rows
     * @param page
     * @return
     */
    @Override
    public JqGridVo querydata(SysFreeze vo, Integer rows, Integer page) {
        PageHelper.startPage(page, rows);
        PageHelper.orderBy("freeze_time DESC");

        Example example = new Example(SysFreeze.class);
        Example.Criteria criteria = example.createCriteria();
        PageUtils.andEqualTo(criteria, "mchId", vo.getMchId());
        PageUtils.andEqualTo(criteria, "outTradeNo", vo.getOutTradeNo());
        PageUtils.andEqualTo(criteria, "serviceType", vo.getServiceType());
        PageUtils.andBetweenDateToDate(criteria, "freezeTime", vo.getFreezeCreateTimeStr(), vo.getFreezeEndTimeStr());
        List<SysFreeze> select = sysFreezeDao.selectByExample(example);

        return PageUtils.pasrJqGrid(select);
    }

    @Override
    public void insert(SysFreeze entity) {

        sysFreezeDao.insert(entity);
    }


}
